package com.jnshu.controller;

import com.jnshu.pojo.UserTaskRelation;
import com.jnshu.service.SignService;
import com.jnshu.service.TaskService;
import com.jnshu.tools.resultUtils.ResultBean;
import com.netflix.ribbon.proxy.annotation.Http;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author Martin
 * @date 2019/8/5 19:02
 * 前台签到接口
 */
@Slf4j
@RestController
public class SignCon {
    @Autowired
    SignService signService;
    @Autowired
    TaskService taskService;

    /**
     * 签到页跳转
     * @return
     */
    @PostMapping(value = "/u/signing")
    public ResultBean signSkip(@RequestParam(value = "id")Long id){
        log.info("feign-web传到person的用户id为："+id);
        return signService.backBySign(id);
    }

    /**
     * 签到页签到
     * @return
     */
    @PutMapping(value = "/u/signing",produces ={"application/json;charset=UTF-8"})
    public ResultBean sign(@RequestParam(value = "id") Long id){
        log.info("feign-web传到person的用户id为："+id);
        return signService.updateByUser(id);
    }

    /**
     * 日常任务查询
     */
    @GetMapping(value = "/u/signing/task")
    public ResultBean everydayTask(@RequestParam(value = "id")Long id){
        log.info("feign-web传过来的用户id为："+id);
        return taskService.everydayTask(id);
    }

    /**
     * 日常任务查询
     */
    @GetMapping(value = "/u/signing/details")
    public ResultBean everydayTaskStatus(@RequestParam(value = "id")Long id){
        log.info("feign-web传过来的用户id："+id);
        return taskService.everydayTaskStatus(id);
    }
}
